package com.charles.springcloud.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: 风中灵劲草
 * @Date: 2021/08/03/16:39
 * @Description:
 */
@RestController
@Slf4j
@RequestMapping("/consumer")
public class OrderConsulController {

    public static final String PAYMENT_URL = "http://consul-provider-payment";   //集群版，"http://" + 微服务名
    @Autowired
    RestTemplate restTemplate;

    @GetMapping("/payment/consul")
    public String paymentInfo(){
        String result = restTemplate.getForObject(PAYMENT_URL + "/payment/consul", String.class);
        return result;
    }
}
